const app = getApp();
import HttpRequst from '../../../utils/httpRequst.js'
import API from '../../../utils/config.js'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    isLoading:false,
    isDataEnd:false,
    pagesize:20,
    fromWhere:"",
    page:1,
    listData:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
   
    var that=this;
    this.setData({
      fromWhere: options.fromwhere ? options.fromwhere:""
    });
    HttpRequst(true, API.uselog,1, app.getUkey(), { page: this.data.page, pagesize: this.data.pagesize}, "POST", false, function (res) {
      
      that.setData({
        listData: res.data.list,
        page:that.data.page+1,
        isDataEnd: (res.data.list.length < that.data.pagesize) ? true :false,
      })
    });
  },

  goToHome:function(){
    wx.reLaunch({
      url: '/pages/index/index/index'
    });
  },

  
  onReachBottom: function () {
    if (this.data.isDataEnd) return;
    var that=this;
    //显示加载更多动画
    this.setData({
      isLoading:true
    })
    //HttpRequst(loading,url,发送header类型, sessionId, params,method, ask, function (res){})
    HttpRequst(false, API.uselog, 1, app.getUkey(), { page: this.data.page, pagesize: this.data.pagesize }, "POST", false, function (res) {
      
      that.setData({
        isLoading:false,
        listData: that.data.listData.concat(res.data.list),
        page: that.data.page + 1,
        isDataEnd: (res.data.list.length < that.data.pagesize) ? true : false,
      })
    });
  },

  _getData:function(typeMethod){
   
  
  }

})